﻿<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="WorkTitleAndRate.aspx.cs"
    Inherits="Basic4Net.OAWeb.Module_Base.WorkTitleAndRate" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title></title>
    <link href="../App_Themes/ui-lightness/main.css" rel="stylesheet" type="text/css" />
</head>
<body>
    <div class="mainWarp">
        <div class="pageBody">
            <form id="form1" runat="server">
            <asp:ScriptManager ID="ScriptManager1" runat="server" EnablePageMethods="true">
            </asp:ScriptManager>
            <input type="button" id="addGroup" value="新增" onclick="OpenGroupSetting(0, '', 0)" class="commonBut" style=" margin-top:8px;"/>
            <asp:UpdatePanel ID="UpdatePanel1" runat="server">
                <ContentTemplate>
                    <asp:Repeater ID="Repeater1" runat="server">
                        <HeaderTemplate>
                            <table id="teacherTable" border="0" cellpadding="0" cellspacing="1" class="useList1" style=" margin-top:8px; width:420px;">
                                <tr class="tableTitle">
                                    <th style="width:300px; text-align:center; padding-left: 5px;">
                                        分类名称
                                    </th>
                                    <th style="width:40px; text-align:center; padding-left: 5px;">
                                        系数
                                    </th>
                                    <th style="width:80px; text-align: center; padding-left: 5px;">
                                    </th>
                                </tr>
                        </HeaderTemplate>
                        <ItemTemplate>
                            <tr>
                                <td style=" text-align:left; padding-left:5px;">
                                    <%#Eval("FName") %>
                                </td>
                                <td style=" text-align:right; padding-right:5px;">
                                    <%#Eval("Factor")%>
                                </td>
                                <td>
                                    <a href="#" onclick="OpenGroupSetting(<%#Eval("RID") %>, '<%#Eval("FName") %>', <%#Eval("Factor") %>)">修改</a>
                                    <a href="#" onclick="IsDelGroup(<%#Eval("RID") %>)">删除</a>
                                </td>
                            </tr>
                        </ItemTemplate>
                        <FooterTemplate>
                            </table>
                        </FooterTemplate>
                    </asp:Repeater>
                </ContentTemplate>
                <Triggers>
                    <asp:AsyncPostBackTrigger ControlID="btnBind" EventName="Click" />
                </Triggers>
            </asp:UpdatePanel>
            <div style="display: none;">
                <asp:Button ID="btnBind" runat="server" OnClick="btnBind_Click" Text="btnBind" />
            </div>
            </form>
            <!-- 新增/修改学校弹出界面 开始-->
            <div id="popTable" class="layoutWarp" style="display: none; width: 280px; overflow: inherit;">
                <div class="title">
                    <span id="formTitle">职称分类设置</span> <a title="关闭" onclick="ClosePopForm('popTable', true);">
                        关闭</a>
                </div>
                <table id="PTableInfo" style="width: 95%; margin-top: 12px;" border="0" class="layoutTable">
                    <tr>
                        <td style=" text-align:right;">
                            <label>
                                分类名称:</label>
                        </td>
                        <td>
                            <input type="text" id="txtGroupName" style=" vertical-align:middle;" />
                        </td>
                    </tr>
                    <tr>
                        <td style=" text-align:right;">
                            <label>
                                系&nbsp;&nbsp;&nbsp;&nbsp;数:</label>
                        </td>
                        <td>
                            <input type="text" id="txtRate" style=" vertical-align:middle;"  onkeypress="if(!this.value.match(/^\d*?\.?\d*$/))event.returnValue=false;" />
                        </td>
                    </tr>
                    <tr>
                        <td colspan="6" align="center">
                            <ul class="butList">
                                <input type="hidden" id="hidID" value=""/>
                                <input type="button" id="btnsave" value="保存" onclick="SaveGroup();" class="commonBut" />
                                <input type="button" value="取消" onclick="ClosePopForm('popTable', true);" class="commonBut" />
                            </ul>
                        </td>
                    </tr>
                </table>
            </div>
        </div>
    </div>
</body>

<script type="text/javascript" src="../Scripts/jquery-1.4.1.js"></script>
<script type="text/javascript" src="../Scripts/common.js"></script>
<script type="text/javascript" src="../Scripts/Util.js"></script>
<script type="text/javascript">
    
    // 打开弹出层
    function OpenGroupSetting(groupID, groupName, groupRate) {
        ShowPopForm("popTable", "formTitle", "职称分类设置", "");
        //showMask();
        if (groupID == 0) {
            $("#hidID").val("0");
            $("#txtGroupName").val("");
            $("#txtRate").val("");
        }
        else {
            $("#hidID").val(groupID);
            $("#txtGroupName").val(groupName);
            $("#txtRate").val(groupRate);
        }
    }

    // 保存分类设置
    function SaveGroup() {
        if (!VerifyData())
            return;

        var groupID = document.getElementById("hidID").value;
        var groupName = document.getElementById("txtGroupName").value;
        var groupRate = document.getElementById("txtRate").value;

        PageMethods.UpdateGroup(Number(groupID), groupName, Number(groupRate),
            function (succ) {
                if (succ == null || succ.length < 1)
                    showMassgeBox("提示", "保存成功", 1);
                else
                    showMassgeBox("提示", succ, 1);
                document.getElementById("<%=btnBind.ClientID %>").click();
                ClosePopForm('popTable', true);
            },
            function (err) {
                if (err == null || err.length < 1)
                    showMassgeBox("提示", "保存失败!", 1);
                else
                    showMassgeBox("提示", err, 1);
                document.getElementById("<%=btnBind.ClientID %>").click();
            }
        );
    }

    // 弹出确认删除对话框
    function IsDelGroup(groupID) {
        showConfirmBox("提示", "确定删除此职称吗?", DelGroup, groupID);
    }
    // 删除职称
    function DelGroup(groupID) {
        PageMethods.DelGroup(Number(groupID),
            function (succ) {
                if (succ == null || succ.length < 1)
                    showMassgeBox("提示", "删除成功!", 1);
                else
                    showMassgeBox("提示", succ, 1);
                document.getElementById("<%=btnBind.ClientID %>").click();
                ClosePopForm('popTable', true);
            },
            function (err) {
                if (err == null || err.length < 1)
                    showMassgeBox("提示", "删除失败", 1);
                else
                    showMassgeBox("提示", err, 1);
                document.getElementById("<%=btnBind.ClientID %>").click();
            }
        );
    }

    // 验证数据
    function VerifyData() {
        var groupName = $("#txtGroupName").val();// document.getElementById("txtGroupName").value;
        var groupRate = $("#txtRate").val(); //document.getElementById("txtRate").value;

        groupName = groupName.trim();
        if (groupName == null || groupName.length < 1) {
            return false;
        }
        document.getElementById("txtGroupName").value = groupName;
        if (!groupRate.match(/^\d*?\.?\d*$/)) {
            return false;
        }
        return true;
    }
</script>

</html>
